package algotithm.weekendrace.leetcode224.test1;

import java.util.HashMap;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/17-23:11
 */
class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] num = {{5,8},{3,9},{3,12}};
        int rectangles = solution.countGoodRectangles(num);
        System.out.println(rectangles);
    }

    public int countGoodRectangles(int[][] rectangles) {
        int res = Integer.MIN_VALUE;
        int k = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < rectangles.length; i++) {
            k = Math.min(rectangles[i][0],rectangles[i][1]);
            map.put(k,map.getOrDefault(k,0) + 1);
        }
        for (Integer key : map.keySet()) {
            res = Math.max(key,res);
        }
        return map.get(res);
    }
}

